<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <script>
        // redux  A
        // redux-thunk  B

        function dispatch(action) {
            if (typeof action === 'object') {
                if (action.type) {
                    console.log('正确')
                } else {
                    throw Error("必须要有type属性")
                }
            } else {
                throw Error("必须要传递一个对象")
            }
        }

        let currentDispatch = dispatch

        dispatch = (action) => {
            if (typeof action === 'function') {
                console.log('我现在可以传递函数了')
            } else {
                currentDispatch(action)
            }
        }

        // console.log(dispatch)


        dispatch({ type: "ADD" })
    </script>
</body>
</html>